<template>
  <div class="ranking">
    <div v-for="(item, index) in show.data" :key="index" class="ranking__row">
      <div class="ranking__cell">
        <div class="ranking__index" :class="`ranking__index-${index + 1}`">
          {{ index + 1 }}
        </div>
      </div>
      <div class="ranking__cell ranking__username">{{ item.username }}</div>
      <div class="ranking__cell ranking__score">{{ item.score }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Ranking',

  data() {
    return {
      show: {
        data: [
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          },
          {
            username: '用户1',
            score: 98
          }
        ]
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.ranking {
  max-height: 250px;
  overflow: auto;
  &__row {
    display: flex;
    padding: 10px 0;
  }

  &__cell {
    flex: 1;
  }

  &__index {
    width: 25px;
    height: 25px;
    text-align: center;
    border-radius: 50%;
    background-color: #f0f2f5;
    // color: #fff;

    &-1,
    &-2,
    &-3 {
      background-color: #000;
      color: #fff;
    }
  }
}
</style>
